/*
 * @Author: wuqingchun
 * @Date: 2024-04-15 20:03:05
 * @Description: 
 * @LastEditors: wuqingchun
 * @LastEditTime: 2024-04-15 20:23:34
 */
#ifndef __MY_LOCK_GUARD_H__
#define __MY_LOCK_GUARD_H__

#include <mutex>

template <typename TLOCK>
class my_lock_guard
{
private:
    /* data */
    TLOCK& m_refLock;
public:
    my_lock_guard(TLOCK& refLock):
        m_refLock(refLock)
    {
        m_refLock.lock();
    }

    ~my_lock_guard()
    {
        m_refLock.unlock();
    }
};

class TestLockGuard
{
public:
    void Test()
    {
        my_lock_guard<std::mutex> objMLG(m_objMutex);
        std::cout << "TestLockGuard" << std::endl;
    }
private:
    std::mutex m_objMutex;
};


#endif //__MY_LOCK_GUARD_H__